<?php
/**
 * @file additional.php
 *
 * Additional functions for developing.
 *
 * Some more functions for easy development with PHP and even the
 * rpd-Framework.
 *
 * http://code.google.com/p/rpd/wiki/additional.php
 *
 * New BSD License
 * \n
 * Copyright (c) 2010 Rpd-Team
 *
 * @namespace  rpd
 * @since      0.0.1
 * @version    0.0.1
 */

/**
 *
 */
function dump($var = NULL)
{
	static $open = false;

	if ($open)
	{
		$open = false;
		echo "</pre></div>";
		if (func_num_args() == 0)
		{
			return NULL;
		}
	}

	$a = debug_backtrace();
	echo "<div><pre>[";
	// file
	$file = str_replace("\\", "/", $a[0]["file"]);
	echo str_replace($_SERVER["DOCUMENT_ROOT"], "", $file);
	// line
	echo ":", $a[0]["line"], "]\n\n";

	if (func_num_args() == 0)
	{
		$open = true;
	}
	else
	{
		ob_start("htmlspecialchars");
		call_user_func_array("var_dump", func_get_args());
		ob_end_flush();
		echo "</pre></div>";
	}
}

function print_backtrace()
{
	echo "<pre>";
	debug_print_backtrace();
	echo "</pre>";
}

?>